package com.cskaoyan.controller;

import com.cskaoyan.bean.GrouponRules;
import com.cskaoyan.bo.GrouponCreateBo;
import com.cskaoyan.bo.GrouponDeleteBo;
import com.cskaoyan.bo.GrouponUpdateBo;
import com.cskaoyan.service.GrouponRulesService;
import com.cskaoyan.vo.BaseRespVo;
import com.cskaoyan.vo.GrouponRulesVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class GrouponController {

    @Autowired
    GrouponRulesService grouponRulesService;

    /**
     * 功能:团购规则页面
     * 作者:whj
     */
    @RequestMapping("admin/groupon/list")
    public BaseRespVo list(Integer page, Integer limit, Integer goodsId, String sort, String order){

        GrouponRulesVo grouponRulesVo = grouponRulesService.query(page,limit,goodsId,sort,order);
        return BaseRespVo.ok(grouponRulesVo);
    }

    /**
     * 功能:团购规则页面,/groupon/create
     * 作者:whj
     */
    @RequestMapping("admin/groupon/create")
    public BaseRespVo create(@RequestBody GrouponCreateBo grouponCreateBo){
        GrouponRules grouponRules = grouponRulesService.create(grouponCreateBo);
        return BaseRespVo.ok(grouponRules);
    }

    /**
     * 功能:团购规则页面,/groupon/update
     * 作者:whj
     */
    @RequestMapping("admin/groupon/update")
    public BaseRespVo update(@RequestBody GrouponUpdateBo grouponUpdateBo){
        grouponRulesService.update(grouponUpdateBo);
        return BaseRespVo.ok();
    }

    /**
     * 功能:团购规则页面,/groupon/delete
     * 作者:whj
     */
    @RequestMapping("admin/groupon/delete")
    public BaseRespVo delete(@RequestBody GrouponDeleteBo grouponDeleteBo){
        grouponRulesService.delete(grouponDeleteBo);
        return BaseRespVo.ok();
    }

    /**
     * 功能:团购活动页面
     * 作者:whj
     * 备注:没有成功的返回值,不做了
     */
    @RequestMapping("admin/groupon/listRecord")
    public BaseRespVo listRecord(Integer page, Integer limit, Integer goodsId, String sort, String order){
        GrouponRulesVo grouponRulesVo = new GrouponRulesVo();
        return BaseRespVo.ok(grouponRulesVo);
    }

}
